package com.odt.outdoor.controller;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;

import com.odt.outdoor.R;
import com.odt.outdoor.framwork.AppStateTracker;
import com.odt.outdoor.model.OnBaseModelListener;
import com.shaomengjie.okhttp.AppException;

public class WelcomeActivity extends AppCompatActivity implements OnBaseModelListener {
    private static final int LOGIN = 1;//已经登录
    private static final int NO_LOGIN = 2;//未登陆
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case LOGIN:
                    startAct();
                    break;
                case NO_LOGIN:
                    startAct();
                    break;
                default:
                    break;
            }
            finish();
        }
    };

    private void startAct() {
        Intent intent = null;
            intent = new Intent(WelcomeActivity.this, MainActivity.class);
        startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppStateTracker.getInstance().setAppState(AppStateTracker.APP_STATE_OFFLINE);
        setContentView(R.layout.activity_welcome);
        initView();
        mHandler.sendEmptyMessageDelayed(LOGIN, 2000);
    }

    private void initView() {

    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onPause() {
        super.onPause();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    @Override
    public boolean onGlobalExceptionHandler(AppException e) {
        return false;
    }
}
